// +----------------------------------------------------------------------
// | Author: dw <827400818@qq.com>
// +----------------------------------------------------------------------
// | 登录页面js
// +----------------------------------------------------------------------
$(function(){
    layui.use(['layer','form'], function(){
        var form = layui.form;
        var layer = layui.layer;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            var action = data.form.action;//表单提交URL地址
            console.log(JSON.stringify(data.field));//表单数据
            $.post(action, data.field, function (obj) {
                //根据返回结果作出相应处理
                if(obj.code != 200){
                    layer.msg(obj.msg,{anim:1,time:1000},function () {
                        location.href = obj.url;
                    });
                }else{
                    layer.msg(obj.msg,{anim: 4, time: 1000},function(){
                        location.href = obj.url;
                    })
                }
            });
            return false;//注释掉这行代码后，表单将会以普通方式提交表单，否则以ajax方式提交表单
        });
    });
})
